home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / amiga.programming / comp.sys.amiga.programmer_10993_000072.msg < prev    next >
Encoding:
Internet Message Format  |  1994-11-27  |  2.2 KB

  1. Path: dd.chalmers.se!news.chalmers.se!sunic!EU.net!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!centre.univ-orleans.fr!univ-lyon1.fr!swidir.switch.ch!scsing.switch.ch!news.dfn.de!rrz.uni-koeln.de!rrz.uni-koeln.de!teralon!dino.dinoco.de!yaps.dinoco.de!arno
  2. From: arno@yaps.dinoco.de (Arno Eigenwillig)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: cloning file handles (was: Re: SystemTagList() Problems)
  5. Message-ID: <7kaPu*CB1@yaps.dinoco.de>
  6. Date: Tue, 17 May 1994 15:34:31 +0100
  7. Reply-To: arno@yaps.dinoco.de
  8. References: <Cp2rEH.M4r@dcs.ed.ac.uk> <mwiMu*2v1@yaps.dinoco.de>
  9.  <2qodc4$d0j@hpsystem1.informatik.tu-muenchen.de>
  10.  <2qosqe$ftt@nemesis.jpl.nasa.gov> <2r0h9s$olb@lily.csv.warwick.ac.uk>
  11. Organization: Yet Another Private Site in Meckenheim, Germany
  12. X-Newsreader: Arn V 1.04
  13. Lines: 48
  14.  
  15. Hi!
  16.  
  17. In article <2r0h9s$olb@lily.csv.warwick.ac.uk>, Ralf writes:
  18.  
  19. > BPTR DupFH(BPTR oldfh)        /* never pass an exclusive fh */
  20. > {
  21. > BPTR lock,fh;
  22. > if (lock=DupLockFromFH(oldfh))
  23. >     {
  24. >     if (fh=OpenFromLock(lock))    /* this does really only take 1 parm */
  25. >         return fh;
  26. >     UnLock(lock);
  27. >     }
  28. > return 0;
  29. > }
  30.  
  31. The above code should be perfect for usual file system files. However,
  32. as the original subject - SystemTagList() problems - brings back to
  33. mind, the original intention was to clone the current input and output
  34. file handles. And these are not guaranteed to be files from which a
  35. lock can be DupLockFromFH()'ed:
  36. - they may be non - file system "files" (such as a console or a pipe)
  37. - they may be files on a file system not supporting the underlying
  38.   ACTION_COPY_DIR_FH packet
  39.  
  40. For interactive "files" there is the way Ralph Babel demonstrates in
  41. his Guru Book:
  42.  
  43.     pr = (struct Process *)FindTask(0);
  44.     oldcontask = pr->pr_ConsoleTask;
  45.     pr->pr_ConsoleTask = <another handler's process ID>;
  46.     fh = Open("*", MODE_NEWFILE);
  47.     pr->pr_ConsoleTask = oldcontask;
  48.  
  49. Similarities to Ralph's ConWindowC.c are admittedly not conincidential.
  50.  
  51. However, I still hold up the statement I made in <-BhLu*7t1@yaps.dinoco.de>:
  52.  
  53. > there is no general way to clone file handles
  54.  
  55. Sad.
  56.  
  57. -- __
  58. __/// Arno Eigenwillig <arno@yaps.dinoco.de>
  59. \XX/  MIME & PGP supported * V:+49-2225-5870 
  60.  
  61. Every real programmer knows that 0x2b | ~0x2b == -1.
  62.